testsuite: Fix an asan error
authorMatthias Clasen <mclasen@redhat.com>
Wed, 8 Jul 2020 19:04:12 +0000 (15:04 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 8 Jul 2020 19:09:08 +0000 (15:09 -0400)
asan complains that some of the memorytexture tests
read past limits. Avoid that.

.gitlab-ci/fedora-base.Dockerfile
testsuite/gdk/memorytexture.c

index 0237b3804b8540816381b3c7e0f61256ff829235..c9e428d54c2805ca3a8c84e7a0f3259aa39ef5cb 100644 (file)
@@ -41,6 +41,7 @@ RUN dnf -y install \
     itstool \
     json-glib-devel \
     lcov \
+    libasan \
     libattr-devel \
     libepoxy-devel \
     libffi-devel \
index b43281e6b2761fcaea35c867d3da907feaf7c805..3f941cdb293310492f23032739f0efe1d5e8d52c 100644 (file)
@@ -93,7 +93,7 @@ create_texture (GdkMemoryFormat  format,
   guchar *data;
   int x, y;
 
-  data = g_malloc (height * stride);
+  data = g_malloc (height * MAX (stride, tests[format].bytes_per_pixel));
   for (y = 0; y < height; y++)
     for (x = 0; x < width; x++)
       {
@@ -102,7 +102,7 @@ create_texture (GdkMemoryFormat  format,
                 tests[format].bytes_per_pixel);
       }
 
-  bytes = g_bytes_new_static (data, height * stride);
+  bytes = g_bytes_new_static (data, height * MAX (stride, tests[format].bytes_per_pixel));
   texture = gdk_memory_texture_new (width, height,
                                     format,
                                     bytes,